home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / visulztn / lise / minilise.lha / minilise / gfxamiga.h < prev    next >
C/C++ Source or Header  |  1993-03-30  |  4KB  |  241 lines

  1. /* include file to provide grafics
  2.    AMIGA SPECIAL VERSION TO SUPPLY RASTPORTS ! */
  3. /* functions supported:
  4.    tekopen();
  5.    vectoa(x,y) int x,y;
  6.    posita(x,y) int x,y;
  7.    dperas();
  8.    gfxfont(number,size) int number,size;
  9.    gfxtext(s,a) char s[]; float a;
  10.    textlen(s) char s[];
  11.    textheight()
  12.    getxy(x,y) int *x,*y;
  13.    gfxflush();
  14.    textparam(sx,sy,tx,ty,w,namw) int sx,sy,tx,ty,w; char *name;
  15.    rmtek();
  16.    setcolour(n) int n;
  17.    special_gfx(s) char *s;          ; do special commands like PostScript output
  18. */
  19.  
  20. #define TMPGCURSOR   "t:gcursor"
  21. #define ASHBDRY      "t:ashbdry" 
  22.  
  23. #define _TEKXMAX 4096
  24. #define _TEKYMAX 3120
  25.  
  26. #ifndef _SPECHDR
  27. #include <spec.h>
  28. #include <auxcfg.h>
  29. #include <libraries/dos.h>
  30. #endif
  31.  
  32. int  _tek4014,
  33.      _tek4014_flg = 0,
  34.      _gfxbufp = 0,
  35.      _gfxfontnr=1,
  36.      _gfxfontsz=1;
  37.  
  38. void  (*positax)(),
  39.       (*vectoax)(),
  40.       (*gfxtextx)(),
  41.       (*dperasx)(),
  42.       (*getxyx)(),
  43.       (*setcolourx)(),
  44.       (*rmtekx)(),
  45.       (*textparamx)(),
  46.       (*hcox)(),
  47.       (*special_gfxx)(),
  48.       (*textlenx)(),
  49.       (*textheightx)();
  50.  
  51. void cvtxy(xx,yy,x,y)
  52. int xx,yy,*x,*y;
  53. {
  54.  
  55.    switch(_win_flg){
  56.    case 0:
  57.       *x=xx ; *y=yy; break;
  58.    case 1:
  59.       *x=xx ; *y=yy/2; break;
  60.    case 2:
  61.       *x=xx ; *y=yy/2 + (_TEKYMAX/2); break;
  62.    case 3:
  63.       *x=xx/2 ; *y=yy/2 + (_TEKYMAX/2); break;
  64.    case 4:
  65.       *x=xx/2 + (_TEKXMAX/2) ; *y=yy/2 + (_TEKYMAX/2); break;
  66.    case 5:
  67.       *x=xx/2 ; *y=yy/2; break;
  68.    case 6:
  69.       *x=xx/2 + (_TEKXMAX/2) ; *y=yy/2; break;
  70.    }
  71. }
  72.  
  73. void vectoa(x,y)
  74. int x,y;
  75. {
  76. int xx,yy;
  77.  
  78.    if(x > _TEKXMAX) x = _TEKXMAX;
  79.    if(x < 0) x = 0;
  80.    if(y > _TEKYMAX) y = _TEKYMAX;
  81.    if(y < 0) y = 0;
  82.    cvtxy(x,y,&xx,&yy);
  83.    (*vectoax)(xx,yy);
  84. }
  85.  
  86. void posita(x,y)
  87. int x,y;
  88. {
  89. int xx,yy;
  90.  
  91.    if(x > _TEKXMAX) x = _TEKXMAX;
  92.    if(x < 0) x = 0;
  93.    if(y > _TEKYMAX) y = _TEKYMAX;
  94.    if(y < 0) y = 0;
  95.    cvtxy(x,y,&xx,&yy);
  96.    (*positax)(xx,yy);
  97. }
  98.  
  99. void gfxtext(s,a)
  100. char s[];
  101. float a;
  102. {
  103. char *z;
  104.  
  105.    z = (char *) malloc(256);
  106.  
  107.    if(_win_flg==0) {
  108.       strcpy(z,"\x1b"); /* normal text size */
  109.       strcat(z,"9");
  110.    } else {
  111.       strcpy(z,"\x1b;"); /* small text size */
  112.    }
  113.    strcat(z,s);
  114.    (*gfxtextx)(z);
  115.  
  116.    free(z);
  117. }
  118.  
  119. void dperas()
  120. {
  121.    (*dperasx)();
  122. }
  123.  
  124. void getxy(x,y) 
  125. int *x,*y;
  126. {
  127. int xx,yy;
  128.  
  129.    (*getxyx)(&xx,&yy);
  130.    cvtxy(xx,yy,x,y);
  131. }
  132.  
  133. void setcolour(n)
  134. int n;
  135. {
  136.    (*setcolourx)(n);
  137. }
  138.  
  139. void rmtek()
  140. {
  141.    (*rmtekx)();
  142. }
  143.  
  144. void textparam(sx,sy,tx,ty,w,name)
  145. int sx,sy,tx,ty,w;
  146. char name[];
  147. {
  148.    (*textparamx)(sx,sy,tx,ty,w,name);
  149. }
  150.  
  151.  
  152. void hco(str)
  153. char str[];
  154. {
  155.    (*hcox)(str);
  156. }
  157.  
  158. void special_gfx(s)
  159. char *s;
  160. {
  161.    (*special_gfxx)(s);
  162. }
  163.  
  164. tekopen()
  165. {
  166. char c,*s,*z,*str;
  167. int n;
  168. struct FileHandle *input, *output;
  169.  
  170.    s = (char *) malloc(80);
  171.    z = (char *) malloc(80);
  172.    str = (char *) malloc(80);
  173.  
  174.    strcpy(s,"gfx");
  175.    c=_tekpipe+48;
  176.    z[0]=c; z[1]=0;
  177.    strcat(s,z);
  178.    _tek4014=auxopen(s); /* _tekpipe is defined in spec.h */
  179.    if(_tek4014 <= 0) {
  180.       strcpy(str,"run >nil: <nil: lise:tekamiga -p "); strcat(str,z);
  181.       input = (struct FileHandle *) Open("nil:",MODE_OLDFILE);
  182.       output = (struct FileHandle *) Open("nil:",MODE_NEWFILE);
  183.       Execute(str,input,output);
  184.       n = 0;
  185.       while(n < 60) {
  186.          Delay(50L);
  187.          _tek4014=auxopen(s); /* _tekpipe is defined in spec.h */
  188.          if(_tek4014 > 0) {Delay(25L); break;}
  189.       }
  190.    }
  191.    if(_tek4014 < 0) {
  192.       fprintf(stderr,"failed to open graphic file\n");
  193.       exit(-1);
  194.    }
  195.    n=read(_tek4014,&positax,4);
  196.    n=read(_tek4014,&vectoax,4);
  197.    n=read(_tek4014,&dperasx,4);
  198.    n=read(_tek4014,&gfxtextx,4);
  199.    n=read(_tek4014,&getxyx,4);
  200.    n=read(_tek4014,&setcolourx,4);
  201.    n=read(_tek4014,&rmtekx,4);
  202.    n=read(_tek4014,&textparamx,4);
  203.    n=read(_tek4014,&hcox,4);
  204.    n=read(_tek4014,&special_gfxx,4);
  205.    n=read(_tek4014,&textlenx,4);
  206.    n=read(_tek4014,&textheightx,4);
  207.    _tek4014_flg=1;
  208.    close(_tek4014); /* open handle makes no sense on the Amiga */
  209.    free(s); free(z); free(str);
  210.    return(_tek4014);
  211. }
  212.  
  213. void gfxflush()
  214. {
  215.    if(_tek4014_flg==0) tekopen();
  216. }
  217.  
  218. textlen(s)
  219. char s[];
  220. {
  221. int n;
  222.  
  223.    (*textlenx)(s,&n);
  224.    return(n);
  225. }
  226.  
  227. textheight()
  228. {
  229. int n;
  230.  
  231.    (*textheightx)(&n);
  232.    return(n);
  233. }
  234.  
  235. void gfxfont(number,size)
  236. int number,size;
  237. {
  238.    _gfxfontnr=number;
  239.    _gfxfontsz=size;
  240. }
  241.